package top.luoqiz.jenkins.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.luoqiz.jenkins.config.sms.store.VerificationCodeStore;
import top.luoqiz.jenkins.utils.ShareCodeUtil;

/**
 * @author luoqiz
 */
@RequestMapping("/jenkins")
@RestController
public class JenkinsController {

    @Autowired
    private VerificationCodeStore verificationCodeStore;

    @GetMapping
    public String testString(String q) {
        if (q == null || q.trim().equals("")) {
            return "您未输入参数，此信息为默认信息。";
        }
        return q;
    }

    @GetMapping("code")
    public boolean testcode(String mobile) {
        String code = ShareCodeUtil.toSerialCode(System.currentTimeMillis());
        verificationCodeStore.save(mobile, code);
        return true;
    }
}
